]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspaceSwitcherPopup: Show on all displays
authorOscar Sommerer <unlined-fielder0y@icloud.com>
Sat, 31 May 2025 18:47:03 +0000 (20:47 +0200)
committerosomm <unlined-fielder0y@icloud.com>
Mon, 16 Jun 2025 12:41:58 +0000 (14:41 +0200)
Show the workspaceSwitcherPopup OSD on all displays if
`workspaces-only-on-primary` is false.

Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8105

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3734>

js/ui/windowManager.js
js/ui/workspaceSwitcherPopup.js

index b74d878e142fea5014b4536931f67e9821ab55d9..05aaeb24018789d3be7b193ec5a93ff390de130f 100644 (file)
@@ -1695,7 +1695,7 @@ export class WindowManager {
         if (!constructor)
             return;
 
-        /* prevent a corner case where both popups show up at once */
+        /* prevent a corner case where both tab and workspace switcher popups show up at once */
         if (this._workspaceSwitcherPopup != null)
             this._workspaceSwitcherPopup.destroy();
 
index bf383d33aa00dd7a4116f03ada37d4f95cc7e2b7..a1b66327d26da0c55fd0eb42e54ff07f7cb1875e 100644 (file)
@@ -1,6 +1,7 @@
 import Clutter from 'gi://Clutter';
 import GLib from 'gi://GLib';
 import GObject from 'gi://GObject';
+import Meta from 'gi://Meta';
 import St from 'gi://St';
 
 import * as Layout from './layout.js';
@@ -9,44 +10,26 @@ import * as Main from './main.js';
 const ANIMATION_TIME = 100;
 const DISPLAY_TIMEOUT = 600;
 
-
-export const WorkspaceSwitcherPopup = GObject.registerClass(
-class WorkspaceSwitcherPopup extends Clutter.Actor {
-    _init() {
-        super._init({
+export const MonitorWorkspaceSwitcherPopup = GObject.registerClass(
+class MonitorWorkspaceSwitcherPopup extends Clutter.Actor {
+    constructor(constraint) {
+        super({
             offscreen_redirect: Clutter.OffscreenRedirect.ALWAYS,
             x_expand: true,
             y_expand: true,
             x_align: Clutter.ActorAlign.CENTER,
             y_align: Clutter.ActorAlign.END,
         });
-
-        const constraint = new Layout.MonitorConstraint({primary: true});
         this.add_constraint(constraint);
 
-        Main.uiGroup.add_child(this);
-
-        this._timeoutId = 0;
-
         this._list = new St.BoxLayout({
             style_class: 'workspace-switcher',
         });
         this.add_child(this._list);
-
-        this._redisplay();
-
-        this.hide();
-
-        let workspaceManager = global.workspace_manager;
-        workspaceManager.connectObject(
-            'workspace-added', this._redisplay.bind(this),
-            'workspace-removed', this._redisplay.bind(this), this);
-
-        this.connect('destroy', this._onDestroy.bind(this));
     }
 
-    _redisplay() {
-        let workspaceManager = global.workspace_manager;
+    redisplay(activeWorkspaceIndex) {
+        const workspaceManager = global.workspace_manager;
 
         this._list.destroy_all_children();
 
@@ -55,22 +38,58 @@ class WorkspaceSwitcherPopup extends Clutter.Actor {
                 style_class: 'ws-switcher-indicator',
             });
 
-            if (i === this._activeWorkspaceIndex)
+            if (i === activeWorkspaceIndex)
                 indicator.add_style_pseudo_class('active');
 
             this._list.add_child(indicator);
         }
     }
+});
+
+export const WorkspaceSwitcherPopup = GObject.registerClass(
+class WorkspaceSwitcherPopup extends Clutter.Actor {
+    constructor() {
+        super();
+
+        this._timeoutId = 0;
+
+        Main.uiGroup.add_child(this);
+
+        this.hide();
+
+        if (Meta.prefs_get_workspaces_only_on_primary()) {
+            const constraint = new Layout.MonitorConstraint({primary: true});
+            this.add_child(new MonitorWorkspaceSwitcherPopup(constraint));
+        } else {
+            const monitors = Main.layoutManager.monitors;
+            monitors.forEach((_, index) => {
+                const constraint = new Layout.MonitorConstraint({index});
+                this.add_child(new MonitorWorkspaceSwitcherPopup(constraint));
+            });
+        }
+
+        const workspaceManager = global.workspace_manager;
+        workspaceManager.connectObject(
+            'workspace-added', this._redisplayAllPopups.bind(this),
+            'workspace-removed', this._redisplayAllPopups.bind(this), this);
+        this.connect('destroy', this._onDestroy.bind(this));
+    }
+
+    _redisplayAllPopups() {
+        for (const popup of this)
+            popup.redisplay(this._activeWorkspaceIndex);
+    }
 
     display(activeWorkspaceIndex) {
         this._activeWorkspaceIndex = activeWorkspaceIndex;
 
-        this._redisplay();
         if (this._timeoutId !== 0)
             GLib.source_remove(this._timeoutId);
         this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, DISPLAY_TIMEOUT, this._onTimeout.bind(this));
         GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._onTimeout');
 
+        this._redisplayAllPopups();
+
         const duration = this.visible ? 0 : ANIMATION_TIME;
         this.show();
         this.opacity = 0;